package com.itheima.springbootinit;

import com.itheima.springbootinit.domain.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Springboot初学
 */
@RestController
public class HelloController {
    @Value("${person.name}")
    private String name;
    @Value("${person.age}")
    private int age;

    @Autowired
    private Environment env;
    @Autowired
    private Person person;

    @RequestMapping("/hello")
    public String hello() {
        System.out.println(age + "****" + name);
        System.out.println("*********");

        System.out.println(env.getProperty("person.name"));
        System.out.println(env.getProperty("person.age"));

        System.out.println(person);
        return "你好，SpringBoot！";
    }
}
